<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>正则表达式</title>
</head>

<body>
    <h1>正则表达式</h1>
</body>
<script>
    // 1.字面量创建
    let str = "abc1231dfaf123213fda";
    let reg = /\d+/g;
    let abc = "1231"
    // let reg = /abc/g;
    let res = str.match(reg);
    console.log(res);

    // 2.构造函数创建
    let str = "abc1231dfaf123213fda";
    let reg = new RegExp("\\d+","g");
    let abc = "1231";
    let reg = new RegExp(abc,"g");
    let res = str.match(reg);
    console.log(res);
</script>

</html>